﻿function add_tr_start(data) {
    // data += "<tr>";
    var res = "<tr>";
    return res;
}
function add_tr_end(data) {
    // data += "</tr>";
    var res = "<tr>";
    return res;
}
function add_td(data) {
    //var str = data;
    var res = "<td>" + data + "</td>";
    return res;
}
function add_td_checkbox(data) {
    var res = "";
    if (data == null) {
        res = "<td><input type='checkbox' value=''" + + "></td>"
    }
    else
        res = "<td><input type='checkbox' value=" + data + "></td>";
    return res;
}
function set_json_data(json) {
    var res = "";
    $.each(json, function (index) {
        res += add_tr_start()
            + add_td_checkbox(json[index].id)
            + add_td(json[index].id)
            + add_td(json[index].clientname)
            + add_td(json[index].devicename)
            + add_td(json[index].deviceid)
            + add_td(json[index].sim)
            + add_td(json[index].register)
            + add_td(json[index].lockdevice)
            + add_td(json[index].zone)
            + add_td(json[index].address)
            + add_td("<a href='#' data-toggle='modal' data-target='#PointsDistributeModal'><span class='icon icon-graph-pie'></span></a>")
            + add_td(json[index].bjkg)
            + add_td("测试操作")
        + add_tr_end();
    });

    $("#item_table tbody").html(res);
    $('.footable-res').footable();//分页
    //当查询到数据时，添加导出excel按钮
    $("#item_table tfoot tr").append("<td><input type='button' class='btn btn-success' value='导出EXCEL'></td>");
}